package com.whfc.mach.dao;

import com.whfc.mach.dto.maintain.MaintainMachDTO;
import com.whfc.mach.dto.maintain.MaintainPayDTO;
import com.whfc.mach.entity.AppMachMaintainPay;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface AppMachMaintainPayMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(AppMachMaintainPay record);

    int insertSelective(AppMachMaintainPay record);

    AppMachMaintainPay selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(AppMachMaintainPay record);

    int updateByPrimaryKey(AppMachMaintainPay record);

    /**
     * 根据保养ids查找
     *
     * @param maintainIds
     * @return
     */
    List<MaintainPayDTO> selectByMaintainIds(@Param("maintainIds") List<Integer> maintainIds);

    /**
     * 根据保养id查找
     *
     * @param maintainId
     * @return
     */
    List<MaintainPayDTO> selectByMaintainId(@Param("maintainId") Integer maintainId);

    /**
     * 批量插入
     *
     * @param deptId
     * @param maintainId
     * @param machId
     * @param machCode
     * @param machTypeName
     * @param maintainDate
     * @param payList
     */
    void batchInsert(@Param("deptId") Integer deptId,
                     @Param("maintainId") Integer maintainId,
                     @Param("machId") Integer machId,
                     @Param("machCode") String machCode,
                     @Param("machTypeName") String machTypeName,
                     @Param("maintainDate") Date maintainDate,
                     @Param("payList") List<MaintainPayDTO> payList);

    /**
     * 逻辑删除
     *
     * @param maintainId
     */
    void deleteLogic(@Param("maintainId") Integer maintainId);

    /**
     * 查找保养的设备
     *
     * @param deptId
     * @param startDate
     * @param endDate
     * @param keyword
     * @return
     */
    List<MaintainMachDTO> selectByDeptIdAndTime(@Param("deptId") Integer deptId,
                                                @Param("startDate") Date startDate,
                                                @Param("endDate") Date endDate,
                                                @Param("keyword") String keyword);

    /**
     * 根据组织机构id和时间查找
     *
     * @param deptId
     * @param startDate
     * @param endDate
     * @param keyword
     * @return
     */
    List<MaintainPayDTO> selectByDeptId(@Param("deptId") Integer deptId,
                                        @Param("startDate") Date startDate,
                                        @Param("endDate") Date endDate,
                                        @Param("keyword") String keyword);

    /**
     * 查找每天保养费用详情
     *
     * @param machIds
     * @param startDate
     * @param endDate
     * @return
     */
    List<MaintainPayDTO> selectDayMaintainPayDetail(@Param("machIds") List<Integer> machIds,
                                                    @Param("startDate") Date startDate,
                                                    @Param("endDate") Date endDate);


}